package com.personnel_management.controller;

import com.personnel_management.pojo.Position;
import com.personnel_management.pojo.Staff;
import com.personnel_management.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@RequestMapping("position")
@Controller
public class PositionController {
    @Autowired
    private PositionService positionService;

    @CrossOrigin("*")
    @RequestMapping("add")
    @ResponseBody
    public Integer addPosition(Position position) {
        return positionService.addPosition(position);
    }

    @CrossOrigin("*")
    @RequestMapping("delete")
    @ResponseBody
    public Integer deletePosition(Integer id) {
        return positionService.deletePosition(id);
    }

    @CrossOrigin("*")
    @RequestMapping("set")
    @ResponseBody
    public Integer setPosition(Position position) {
        return positionService.setPosition(position);
    }

    @CrossOrigin("*")
    @RequestMapping("selectAll")
    @ResponseBody
    public List<Position> selectAll() {
        return positionService.selectAll();
    }

    @CrossOrigin("*")
    @RequestMapping("selectByName")
    @ResponseBody
    public List<Position> selectByName(String name) {
        return positionService.selectByName(name);
    }

    @CrossOrigin("*")
    @RequestMapping("selectByWages")
    @ResponseBody
    public List<Position> selectByWages(Double min, Double max) {
        return positionService.selectByWages(min, max);
    }

    @CrossOrigin("*")
    @RequestMapping("selectStaffs")
    @ResponseBody
    public List<Staff> selectStaffs(int id) {
        return positionService.selectStaffs(id);
    }
}
